/**
 * 斐波那契数列
 * [1,1,2,3,5,8,13,21,...]
 * 前两项固定，都是1
 */
function fibonacci(n) {
  let arr = [1, 1];
  let i = n + 1 - 2;
  while (i > 0) {
    let a = arr[arr.length - 2];
    let b = arr[arr.length - 1];
    arr.push(a + b);
    i--;
  }
  return arr[arr.length - 1]
}

function fibonacci1(n) {
  function fn(count, cur = 1, next = 1) {
    if (count === 0) {
      return cur
    } else {
      fn(count - 1, next, next + cur)
    }
  }
  return fn(n)
}